//
//  TRTCAudioViewController.swift
//  onemeetingmac
//
//  Created by 张衡 on 2020/3/13.
//  Copyright © 2020 onemeeting. All rights reserved.
//

import Foundation

class TRTCAudioViewController: BaseViewController {
    
    var isPhone:Bool = false {
        didSet {
            self.compView.isHidden = isPhone
            self.phoneView.isHidden = !isPhone
        }
    }
    
    override func loadView() {
        let view = NSView.init(frame: NSRect.init(x: 0, y: 0, width: kAudioWindowWidth, height: kAudioWindowHeight))
        view.wantsLayer = true
        view.layer?.backgroundColor = NSColor.white.cgColor
        self.view = view
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.setupUI()
    }
    
    
    
    func setupUI()  {
        
        self.view.addSubview(slide)
        slide.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-50)
            make.centerX.equalToSuperview()
            make.height.equalTo(26)
            make.top.equalTo(20)
        }
        
        self.view.addSubview(tabar)
        tabar.snp.makeConstraints { (make) in
            make.height.equalTo(40)
            make.centerX.width.bottom.equalToSuperview()
        }
        
        self.view.addSubview(compView)
        compView.snp.makeConstraints { (make) in
            make.left.right.equalToSuperview()
            make.top.equalTo(60)
            make.bottom.equalTo(tabar.snp.top)
        }
        
        self.view.addSubview(phoneView)
        phoneView.snp.makeConstraints { (make) in
            make.left.right.equalToSuperview()
            make.top.equalTo(60)
            make.bottom.equalTo(tabar.snp.top)
        }
    }
    lazy var phoneView: PhoneAudioView = {
        let view = PhoneAudioView()
        view.isHidden = true
        return view
    }()
    lazy var compView: CompAudioView = {
        let view = CompAudioView()
        return view
    }()
    
    lazy var slide: AudioSlide = {
        let view = AudioSlide()
        view.delegate = self
        return view
    }()
    lazy var tabar: TRTCAudioTab = {
        let view = TRTCAudioTab()
        return view
    }()
    
}


extension TRTCAudioViewController: AudioSlideDelegate{
    func audioSlide_didSelectBtn(audioSlide: AudioSlide, senber: ZHButton, index: Int) {
        let isok = index == 0 ? true:false
        self.isPhone = isok
    }
    
    
}
